"""admin schemas模型"""

# optional选填：Optional[datetime],Optional[datetime] = None
from typing import Optional

from pydantic import BaseModel
from datetime import datetime


class AdminBase(BaseModel):  # 基础模型
    ad_name: str
    adminname: str

class Admin(AdminBase):  # 与数据库对应的响应模型
    ad_id: int  # 没有默认值，必填字段；有默认值，选填字段
    ad_name: str
    adminname: str
    password: str
    created_at: datetime
    updated_at: datetime


class AdminCreate(AdminBase):  # 管理员输入创建模型
    ad_name: str
    adminname: str
    password: str


class AdminUpdate(AdminBase):  # 管理员输入更新模型
    password: str


class AdminRead(AdminBase):
    ad_id: int
    ad_name: str
    password: str
    created_at: datetime
    updated_at: datetime

    class Config:             # 兼容ORM模型,为Pydantic开启验证
        orm_mode = True


